abstract class Animal {
    // 基本属性
    String name;
    String type;
    String breed;
    double price;

    // 构造方法
    public Animal(String name, String type, String breed, double price) {
        this.name = name;
        this.type = type;
        this.breed = breed;
        this.price = price;
    }

    // 基本方法
    public void eat() {
        System.out.println(name + " is eating.");
    }

    public void sleep() {
        System.out.println(name + " is sleeping.");
    }

    // 抽象方法，子类需要实现
    public abstract void play();

    // 抽象方法，子类可以选择实现（这里为了通用性放在这里，但小猫有特殊情况）
    public void makeSound() {
        System.out.println(name + " makes a sound.");
    }
}
class Cat extends Animal {
    public Cat(String name, String type, String breed, double price) {
        super(name, type, breed, price);
    }

    @Override
    public void play() {
        System.out.println(name + " is playing and making a meow sound.");
        makeSound(); // 在玩的时候调用叫的方法
    }

    @Override
    public void makeSound() {
        System.out.println(name + " meows.");
    }
}
class Dog extends Animal {
    public Dog(String name, String type, String breed, double price) {
        super(name, type, breed, price);
    }

    @Override
    public void play() {
        System.out.println(name + " is playing.");
    }

    @Override
    public void makeSound() {
        System.out.println(name + " barks.");
    }
}
public class Main {
    public static void main(String[] args) {
        // 实例化小猫对象
        Animal cat1 = new Cat("Whiskers", "Cat", "Persian", 500.0);
        Animal cat2 = new Cat("Mittens", "Cat", "Siamese", 400.0);

        // 实例化小狗对象
        Animal dog1 = new Dog("Buddy", "Dog", "Golden Retriever", 800.0);
        Animal dog2 = new Dog("Daisy", "Dog", "Poodle", 700.0);

        // 调用方法
        cat1.eat();
        cat1.sleep();
        cat1.play(); // 这里会调用makeSound()

        dog1.eat();
        dog1.sleep();
        dog1.play();
        dog1.makeSound();

        // 测试其他对象
        cat2.eat();
        dog2.makeSound();
    }
}